/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package transport;
import java.util.LinkedList;
/**
 *
 * @author Miguel
 */
public class Station {
    private String titre;
    private int[] trajet;
    private int[] chargement;
    private boolean occuper;
    private LinkedList<String> fil;
    
    public Station(String titre, int[] trajet, int[] chargement){
        this.titre = titre;
        this.trajet = trajet;
        this.chargement = chargement;
        occuper = false;
        fil = new LinkedList<>();
    }
    
    public boolean isOccuper(){
        return occuper;
    }
    public void liberPlace(){
        occuper = false;
    }
    
    public int charge(){
        if(occuper){return -1;}
        else{
            occuper = true;
            return Clock.random(chargement[0], chargement[1]);
        }
    }
    
    public int dureeTrajet(){
        return Clock.random(trajet[0], trajet[1]);
    }
    
    public void addAttent(String nom){
        fil.addLast(nom);
    }
    public boolean isFirstAttent(String nom){
        boolean temp = fil.isEmpty() ? true : fil.element().equals(nom);
        if(temp && !fil.isEmpty()){
            fil.removeFirst();
        }
        return temp;
    }
}
